package com.example.interviewdemo.demo;

/**
 * @program my-project-model
 * @description:死锁的例子并解决死锁
 * @author: lee
 * @create: 2022/12/29 09:27
 */
public class Main {
    public static void main(String[] args) {
//        Object object1 = new Object();
//        Object object2 = new Object();
//
//
//        Thread1 thread1 = new Thread1();
//        synchronized (object1) {
//            thread1.run();
//            synchronized (object2) {
//                System.out.println("线程1尝试获取锁2");
//            }
//
//        }
//
//
//        Thread2 thread2 = new Thread2();
//        synchronized (object2) {
//            thread2.run();
//            synchronized (object1) {
//                System.out.println("线程2尝试获取锁1");
//            }
//        }

        Thread1 thread1 = new Thread1();
        new Thread(thread1).start();
        System.out.println("线程2开始执行");
        Thread2 thread2 = new Thread2();
        new Thread(thread2).start();


    }

}
